package com.yanqu.road.server.cmd.newmonopolymkt;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.newmonopolymkt.NewMonopolyMarketProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.systemgroup.newmonopolymarket.NewMonopolyMarketMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;


@Cmd(code = GameProtocol.S_NEW_MONOPOLY_MARKET_SYN_ATTACK, desc = "榷场同步玩家攻击信息  跨服返回区服 协议")
public class NewMonopolyMarketSynAttackFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        NewMonopolyMarketProto.NewMonopolyMarketSynAttackToGameServerMsg reqMsg = NewMonopolyMarketProto.NewMonopolyMarketSynAttackToGameServerMsg.parseFrom(packet.getBytes());
        GamePlayer player = GamePlayerMgr.getOnlinePlayer(reqMsg.getRobedId());
        NewMonopolyMarketMgr.addReport(player,reqMsg);
        if(player != null){
            NewMonopolyMarketMgr.refreshUser(player,true,false);
            //被打，要更新派遣队伍
            NewMonopolyMarketMgr.leaveResGrabPoint(player, reqMsg.getResGroupId(), reqMsg.getPosIndex(), true);
        }
    }
}
